package com.zsrt.java.day20161226.zzd.demo2;

import java.util.Scanner;

public class CalTest02 {
	public static int add(int x ,int y){
		return x+y;
	}
	public static int sub(int x ,int y){
		return x-y;
	}
	public static int mul(int x ,int y){
		return x*y;
	}
	public static int chu(int x ,int y){
		
		if(y==0){
			return 0;
		}
		return x/y;
	}
	public static int mo(int x ,int y){
		return x%y;
	}
	
	public static int cal(String flag,int x, int y){
		int jg=0;
		switch (flag) {
			case "+":jg=add(x,y);break;
			case "-":jg=sub(x,y);break;
			case "*":jg=mul(x,y);break;
			case "/":jg=chu(x,y);break;
			case "%":jg=mo(x,y);break;
		}
		return jg;
	}
	
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		while(true){
			
			System.out.println("请输入符号...");
			
			String  flag  = sc.next();
			
			if(flag.equals("quit")){
				break;
			}
			System.out.println("请输入第1个数...");
			int x  = sc.nextInt();
			
			System.out.println("请输入第2个数...");
			int y = sc.nextInt();
			
			int abc =cal(flag, x, y);
			System.out.println(abc);
			
		}
		sc.close();
	}

}
